<template>
  <div id="app">

    <keep-alive>
      <router-view v-if="$route.meta.keepAlive"></router-view>
    </keep-alive>

    <router-view v-if="!$route.meta.keepAlive"></router-view>
  </div>
</template>

<script>

  import {isWechat, wechatConfig} from '@/lib/wechat.js';
  import util from './lib/util'

  export default {
    name: 'App',
    created() {
    },
    methods: {
      login: function (isCollect) {
        return new Promise((resolve, reject) => {
          util.ajax.get('user/get').then((res) => {
            if (res.code == '1201'||res.code == '1202') {
              this.$toast('请先登录', {
                duration: '1000'
              });

              if (isCollect) {
                //登录数据埋点
                window.sessionStorage.setItem('routerForm', isCollect);
              }
              setTimeout(() => {
                this.$router.push({name: 'Login'})
              }, 1000)
            }
//            else if (res.code == '1202') {
//              this.$toast('请先绑定手机号', {
//                duration: '1000'
//              });
//              setTimeout(() => {
//                this.$router.push({name: 'BindingNumber'})
//              }, 1000)
//            }
            else {
              if (res.code == 1) {
                // 登录成功清掉阅读计数
                sessionStorage.removeItem("readCount")
              }
              resolve(res);
            }
          });
        })
      }
    }
  }
</script>

<style lang="scss">
  @import "assets/css/style.scss";
</style>
